﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZFB.Models.EntityConfig
{
    internal class CitiesConfig :IEntityTypeConfiguration<T_Cities>
    {
        public void Configure(EntityTypeBuilder<T_Cities> builder)
        {
            builder.ToTable("T_Cities");
            
            builder.HasMany(e=>e.T_Regions).WithOne(e => e.T_Cities).HasForeignKey(e => e.CityId).OnDelete(DeleteBehavior.Restrict);
            
            builder.HasMany(e=>e.T_Users).WithOne(e => e.T_Cities).HasForeignKey(e => e.CityId).OnDelete(DeleteBehavior.Restrict);
        } 
    }
} 
